<template>
	<view style="padding-top: 40upx;">
		<button class="avatar" open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar">
			<image :src="avatarUrl"></image>
		</button>
		<input type="nickname" class="weui-input" placeholder="请输入昵称" />
	</view>
</template>

<script>
	const defaultAvatarUrl =
		'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'

	export default {
		components: {},
		data() {
			return {
				avatarUrl: defaultAvatarUrl,
			}
		},
		onLoad() {},
		methods: {
			onChooseAvatar(e) {
				const {
					avatarUrl
				} = e.detail
				this.avatarUrl = avatarUrl
				// uniCloud.uploadFile({
				// 	filePath: avatarUrl,
				// 	cloudPath: Date.now() + '.mp4',
				// 	onUploadProgress: function(progressEvent) {
				// 		that.progress = (progressEvent.loaded / progressEvent.total) *
				// 			100
				// 	},
				// 	success: function(res) {
				// 		if (res.success == true) {
				// 			that.show = false
				// 			that.$refs.uToast.show({ //提示成功并返回上个页面
				// 				title: '上传成功！',
				// 				type: 'success',
				// 				icon: true,
				// 				duration: 2000,
				// 			})
				// 			that.src = res.fileID
				// 			that.$emit("callVadio", that.src)
				// 		}
				// 	},
				// 	fail(err) {
				// 		console.log(err)
				// 	},
				// });
			}
		}
	}
</script>

<style>
	.avatar {
		width: 80px;
		height: 80px;
		padding: 0;
		background: none;
	}

	.avatar image {
		width: 80px;
		height: 80px;
		border-radius: 100px;
	}

	.weui-input {
		width: 90%;
		height: 60px;
		margin: 20px auto;
		background: #eee;
		border-radius: 5px;
		padding-left: 15px;
	}
</style>
